package com.ruoyi.web.controller.proposals;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.proposals.domain.ProProposals;
import com.ruoyi.proposals.service.ProProposalsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * 提案管理
 * 
 */
@Api(tags = "提案管理")
@RestController
@RequestMapping("/pro/proposals")
public class ProProposalsController extends BaseController {

    @Autowired
    private ProProposalsService proposalsService;

    /**
     * 获取提案列表
     */
    @ApiOperation("获取提案列表")
    @GetMapping("/list")
    public TableDataInfo list(ProProposals proposals) {
        startPage();
        List<ProProposals> list = proposalsService.selectList(proposals);
        return getDataTable(list);
    }

    /**
     * 删除提案
     */
    @ApiOperation("删除提案")
    @PostMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        proposalsService.deleteByIds(ids); // 推荐使用 removeByIds
        return success();
    }
    @ApiOperation("导出提案")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProProposals proposals) {
        List<ProProposals> list = proposalsService.selectList(proposals);
        ExcelUtil<ProProposals> util = new ExcelUtil(ProProposals.class);
        util.exportExcel(response, list, "提案列表");
    }


}
